﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace Toom.CellularAutomata.Common
{
	public class CASettings
	{
		public static bool UseMultiCPU = true;
		public static bool UseNeighborOpt = false;


		public static int valMin, valMax;
		public static int fieldSizeX, fieldSizeY;

		public static bool drawEnabled = false;
		public static bool drawLines = false;
		public static int selectedColor = -1;
		public static System.Drawing.Color[] colorsDefault;
		public static System.Drawing.Color[] colors;


		public static CAOptimization Optimization
		{
			get
			{
				if ( UseNeighborOpt )
					return CAOptimization.Life;
				else
					return CAOptimization.None;
			}
		}



		public static void Setup()
		{
			colorsDefault = new Color[]
				{
					Color.Black,
					Color.DarkViolet,
					Color.DarkBlue,
					Color.SkyBlue,
					Color.Green,
					Color.Yellow,
					Color.Orange,
					Color.Red,
					Color.White
				};
		}

		public static void SetupColors(int maxVal)
		{
			Random r = new Random( DateTime.Now.Millisecond );

			colors = new Color[maxVal+1];
			for ( int color=0 ; color<=maxVal ; color++ )
			{
				if ( color < colorsDefault.Length )
					colors[color] = colorsDefault[color];
				else
				{
					colors[color] = Color.FromArgb( r.Next( 256 ), r.Next( 256 ), r.Next( 256 ) );
				}
			}

		}


	}


	public enum CAOptimization
	{
		None = 0,
		Life
	}

}
